﻿using System.Collections.Generic;
using Dimebrain.TweetSharp.Model;
using Dimebrain.TweetSharp.Model.Twitter.Converters;
using Newtonsoft.Json;

namespace Dimebrain.TweetSharp.Extensions
{
    partial class TwitterExtensions
    {
        // todo move to core extension
        public static string ToJson(this IModel instance)
        {
            var json = JsonConvert.SerializeObject(instance, 
                new TwitterDateTimeConverter(),
                new TwitterWonkyBooleanConverter());

            return json;
        }

        // todo move to core extension
        public static string ToJson(this IEnumerable<IModel> collection)
        {
            var json = JsonConvert.SerializeObject(collection, 
                new TwitterDateTimeConverter(),
                new TwitterWonkyBooleanConverter());

            return json;
        }
    }
}
